{# src/Pyaf/GymBundle/Resources/views/AdminRutina/list.html.twig #}
{% extends "PyafGymBundle::layout_admin.html.twig" %}

{% block title %} Pyaf {% endblock %}
{% block tituloSector %}<i class=" icon-list-alt"></i> Rutinas - Administrar Rutinas {% endblock %}
{% block nombreSector %} Rutinas / Rutinas{% endblock %}
{% block dashboardContent %}{% endblock %}

{% block content %}
    <div class="container-fluid" id="content-area" style="padding-right: 30px;">    
        
        {% if app.session.hasFlash('alertaRutinaSuccess') %}
            <div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                {{ app.session.flash('alertaRutinaSuccess') }}
            </div>
        {% endif %}
        {% if app.session.hasFlash('alertaRutinaError') %}
            <div class="alert alert-error">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                {{ app.session.flash('alertaRutinaError') }}
            </div>
        {% endif %}
        
    <div class="row-fluid">
        <div class="span12">
            <div class="box">
                <div class="box-head"><i class="icon-table"></i><span>Tablero de Rutinas</span></div>
                <div class="box-body">
                    
                    <div class="span6">
                        <div class="mini-layout">
                            <div class="mini-layout-header">
                                <i class="icon-th-large"></i>
                                <span>Rutinas</span>
                            </div>
                            <div class="mini-layout-body">
                                <table id="table" class="table table-nomargin table-bordered dataTable table-striped table-hover">
                                    <thead><tr>                                              
                                            <th>Nombre</th>
                                            <th>Habilitado</th>
                                            <th>Editar</th>
                                            <th>In/Habilitar</th>
                                    </tr></thead>
                                    <tbody>

                                    {% for rutina in rutinas %}

                                        <tr style="">
                                            <td><div class="btn-link" onclick='showRutina("{{ path('admin_rutina_show', { 'id': rutina.id }) }}")'>
                                                {{rutina.nombre}}
                                            </div></td>
                                            <td style="text-align: center;">
                                                {% if rutina.habilitado %}
                                                    <i class="icon-check"></i>
                                                {% else %}
                                                    <i class="icon-check-empty"></i>
                                                {% endif %}                                            
                                            </td>
                                            <td style="text-align: center;"><div class="btn-link icon-edit" onclick='showRutina("{{ path('admin_rutina_edit', {'id': rutina.id}) }}")'></div></td>
                                            <td style="text-align: center;"><a class="btn-link  icon-remove-sign" href="{{ path('admin_rutina_disable', {'id': rutina.id}) }}"></div></td>
                                        </tr>

                                    {% endfor %}

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="span6">
                        <div class="mini-layout">
                            <div class="mini-layout-header">
                                <i class="icon-leaf"></i>
                                <span>Rutina</span>
                                <button class="btn-mini btn-primary text-right offset5" id="newRutina">
                                    Agregar nueva rutina
                                </button>
                            </div>
                            <div class="mini-layout-body">
                                <div id="box-info-rutina"></div>  
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>            
 </div>
{% endblock %}
    
{% block javascripts %}
    <script type="text/javascript">

        function showRutina(data){                
            $('#box-info-rutina').load(data);             
        };

        $(document).ready(function(){
                    
            $('#newRutina').click(function(){
                showRutina("{{ path('admin_rutina_new') }}");
            });
             
        });
    </script>
{% endblock %}